Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

188
Views
El programa dice que "setVisible(false)" no es una función, ¿a qué se debe este problema?

Estoy haciendo un programa en Phaser en JavaScript y estoy usando la instrucción questions.setVisible(false) en mi programa, pero aparece: Uncaught TypeError: question.setVisible is not a function , que claramente lo es. La declaración está en la función de create , tampoco funciona en las otras funciones. Código:

 var Game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', {create}) var question; function create() { question = Game.add.text(Game.width/2, Game.height/2, 'On which day is Pi celebrated?', {align: 'center'}).anchor.setTo(0.5); question.setVisible(false); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Recomendaría usar Phaser 3 , no Phaser 2/CE/... más o menos. Dado que la mayoría de las documentaciones e información son para Phaser 3. Dicho esto, me parece que su problema es doble:

  1. no puede encadenar todas las propiedades/métodos de esta manera, ya que los comentarios mencionan que devuelve un objeto diferente. Tendrías que hacer esto:

     // like this `question` is a Text object question = game.add.text(game.width/2,game.height/2, 'On which day is Pi celebrated?', {align: 'center', stroke:'white', fill:'white'}); // set the anchor of the `question` question.anchor.setTo(0.5);
  2. la función setVisible no existe para la clase de texto. (al menos no se menciona en la documentación , nota al margen: en phaser3 existe esta función). Para Phaser 2/CE tendría que establecer la propiedad visible :

     question.visible = false;

Así que toda la función debería verse así:

 function create() { question = game.add.text(game.width/2,game.height/2, '...', {align: 'center'}); question.anchor.setTo(0.5); question.visible = false; }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!